<?php 
include_once dirname(__FILE__)."/db.class.php" ;
 class personne{
		 protected $_result;
		 protected $_cnn;
		 protected $_NO;
		 protected $_Civilite;
		 protected $_Titre;
		 protected $_Nom;
		 protected $_Prenom;
		 protected $_CIN;
		 protected $_login;
		 protected $_MotPasse;
		 protected $_Mail;
		 protected $_AdressePostale;
		 protected $_NumTelephone;
		 protected $_NumFax;
		 protected $_NumMobile;
		 protected $_CategorieUsager;
		 protected $_CategoriePrincipaleUsager;
		 protected $_IdentifiantInstitutionnel;
		 protected $_OrganismeRattachement;
		 protected $_LMD;
		 protected $_Discipline;
		 
		  public $_autreuniversite;
		   public $_autreetablissement;
		 		 
	
		 protected $_ville;
		 	 protected $_code_type_cand;
			 	 protected $_fonction;
				 	 protected $_grade;
						protected $_specialite;
						
					
		 public function get_name_table(){ return "personne";}
		 public function get_name_NO(){ return "NO";}
		 public function get_name_Civilite(){ return "Civilite";}
		 public function get_name_Titre(){ return "Titre";}
		 public function get_name_Nom(){ return "Nom";}
		 public function get_name_Prenom(){ return "Prenom";}
		 public function get_name_CIN(){ return "CIN";}
		 public function get_name_login(){ return "login";}
		 public function get_name_MotPasse(){ return "MotPasse";}
		 public function get_name_Mail(){ return "Mail";}
		 public function get_name_AdressePostale(){ return "AdressePostale";}
		 public function get_name_NumTelephone(){ return "NumTelephone";}
		 public function get_name_NumFax(){ return "NumFax";}
		 public function get_name_NumMobile(){ return "NumMobile";}
		 public function get_name_CategorieUsager(){ return "CategorieUsager";}
		 public function get_name_CategoriePrincipaleUsager(){ return "CategoriePrincipaleUsager";}
		 public function get_name_IdentifiantInstitutionnel(){ return "IdentifiantInstitutionnel";}
		 public function get_name_OrganismeRattachement(){ return "OrganismeRattachement";}
		 public function get_name_LMD(){ return "LMD";}
		 public function get_name_Discipline(){ return "Discipline";}
		 public function get_name_Code_type_cand(){ return "code_type_cand";}
		 public function get_name_Ville(){ return "ville";}
		 
		 public function get_name_fonction(){ return "fonction";}
		 public function get_name_grade(){ return "grade";}
		 		 public function get_name_specialite(){ return "specialite";}
		 

		 
		 public function set_NO($parametre){  $this->_NO=$parametre;}	
		 public function set_Civilite($parametre){  $this->_Civilite=$parametre;}	
		 public function set_Titre($parametre){  $this->_Titre=$parametre;}	
		 public function set_Nom($parametre){  $this->_Nom=$parametre;}	
		 public function set_Prenom($parametre){  $this->_Prenom=$parametre;}	
		 public function set_CIN($parametre){  $this->_CIN=$parametre;}	
		 public function set_login($parametre){  $this->_login=$parametre;}	
		 public function set_MotPasse($parametre){  $this->_MotPasse=$parametre;}	
		 public function set_Mail($parametre){  $this->_Mail=$parametre;}	
		 public function set_AdressePostale($parametre){  $this->_AdressePostale=$parametre;}	
		 public function set_NumTelephone($parametre){  $this->_NumTelephone=$parametre;}	
		 public function set_NumFax($parametre){  $this->_NumFax=$parametre;}	
		 public function set_NumMobile($parametre){  $this->_NumMobile=$parametre;}	
		 public function set_CategorieUsager($parametre){  $this->_CategorieUsager=$parametre;}	
		 public function set_CategoriePrincipaleUsager($parametre){  $this->_CategoriePrincipaleUsager=$parametre;}	
		 public function set_IdentifiantInstitutionnel($parametre){  $this->_IdentifiantInstitutionnel=$parametre;}	
		 public function set_OrganismeRattachement($parametre){  $this->_OrganismeRattachement=$parametre;}	
		 public function set_LMD($parametre){  $this->_LMD=$parametre;}	
		 public function set_Discipline($parametre){  $this->_Discipline=$parametre;}
		 public function set_Code_type_cand($parametre){ $this->_code_type_cand=$parametre;}		 
		 
		 public function set_fonction($parametre) { $this->_fonction=$parametre;} 
		  public function set_grade($parametre) { $this->_grade=$parametre;} 
		 		 public function set_specialite($parametre){  $this->_specialite=$parametre; }
				 

		  
		  
		 public function set_Ville($parametre){ $this->_ville=$parametre;}
		 public function get_result(){ return $this->_result;}
		 public function get_NO(){ return $this->_NO;}
		 public function get_Civilite(){ return $this->_Civilite;}
		 public function get_Titre(){ return $this->_Titre;}
		 public function get_Nom(){ return $this->_Nom;}
		 public function get_Prenom(){ return $this->_Prenom;}
		 public function get_CIN(){ return $this->_CIN;}
		 public function get_login(){ return $this->_login;}
		 public function get_MotPasse(){ return $this->_MotPasse;}
		 public function get_Mail(){ return $this->_Mail;}
		 public function get_AdressePostale(){ return $this->_AdressePostale;}
		 public function get_NumTelephone(){ return $this->_NumTelephone;}
		 public function get_NumFax(){ return $this->_NumFax;}
		 public function get_NumMobile(){ return $this->_NumMobile;}
		 public function get_CategorieUsager(){ return $this->_CategorieUsager;}
		 public function get_CategoriePrincipaleUsager(){ return $this->_CategoriePrincipaleUsager;}
		 public function get_IdentifiantInstitutionnel(){ return $this->_IdentifiantInstitutionnel;}
		 public function get_OrganismeRattachement(){ return $this->_OrganismeRattachement;}
		 public function get_LMD(){ return $this->_LMD;}
		 public function get_Discipline(){ return $this->_Discipline;}
		 public function get_Code_type_cand(){ return $this->_code_type_cand;}	
		 public function get_Ville(){ return $this->_ville;}	
		 
		 public function get_specialite(){  return $this->_specialite; }
		 public function get_grade() { return $this->_grade;} 
		 public function get_fonction() { return $this->_fonction;} 

		 
public function __construct(){
			
		 	$this->_cnn=new Db();

		 }

 public function INSERT()
{

$sql=" INSERT INTO 
 personne(
			Civilite,
			Titre,
			Nom,
			Prenom,
			CIN,
			login,
			MotPasse,
			Mail,
			AdressePostale,
			NumTelephone,
			NumFax,
			NumMobile,
			CategorieUsager,
			CategoriePrincipaleUsager,
			IdentifiantInstitutionnel,
			OrganismeRattachement,
			LMD,
			Discipline,
			code_type_cand,
			ville,
			fonction,
			grade,
			specialite,
			autreuniversite,
			autreetablissement
			)
 VALUES(
			'".$this->_Civilite."',
			'".$this->_Titre."',
			'".$this->_Nom."',
			'".$this->_Prenom."',
			'".$this->_CIN."',
			'".$this->_login."',
			'".$this->_MotPasse."',
			'".$this->_Mail."',
			'".$this->_AdressePostale."',
			'".$this->_NumTelephone."',
			'".$this->_NumFax."',
			'".$this->_NumMobile."',
			'".$this->_CategorieUsager."',
			'".$this->_CategoriePrincipaleUsager."',
			'".$this->_IdentifiantInstitutionnel."',
			'".$this->_OrganismeRattachement."',
			'".$this->_LMD."',
			'".$this->_Discipline."',
			'".$this->_code_type_cand."',
			'".$this->_ville."',
			'".$this->_fonction."',
			'".$this->_grade."',
			'".$this->_specialite."',
			'".$this->_autreuniversite."',
			'".$this->_autreetablissement."'
			
			)";
		//	////echo $sql;
$this->_cnn->connect();
$this->_result=$this->_cnn->query($sql);

$this->_cnn->disconnect();

 if(!$this->_result){return false;}else{return true;}
}

 public function UPDATE()
{

 $sql="";
if(!empty($this->_Civilite)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
Civilite='".$this->_Civilite."'";
}
if(!empty($this->_Titre)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
Titre='".$this->_Titre."'";
}
if(!empty($this->_Nom)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
Nom='".$this->_Nom."'";
}
if(!empty($this->_Prenom)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
Prenom='".$this->_Prenom."'";
}
if(!empty($this->_CIN)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
CIN='".$this->_CIN."'";
}
if(!empty($this->_login)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
login='".$this->_login."'";
}
if(!empty($this->_MotPasse)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
MotPasse='".$this->_MotPasse."'";
}
if(!empty($this->_Mail)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
Mail='".$this->_Mail."'";
}
if(!empty($this->_AdressePostale)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
AdressePostale='".$this->_AdressePostale."'";
}
if(!empty($this->_NumTelephone)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
NumTelephone='".$this->_NumTelephone."'";
}
if(!empty($this->_NumFax)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
NumFax='".$this->_NumFax."'";
}
if(!empty($this->_NumMobile)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
NumMobile='".$this->_NumMobile."'";
}
if(!empty($this->_CategorieUsager)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
CategorieUsager='".$this->_CategorieUsager."'";
}
if(!empty($this->_CategoriePrincipaleUsager)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
CategoriePrincipaleUsager='".$this->_CategoriePrincipaleUsager."'";
}
if(!empty($this->_IdentifiantInstitutionnel)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
IdentifiantInstitutionnel='".$this->_IdentifiantInstitutionnel."'";
}
if(!empty($this->_OrganismeRattachement)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
OrganismeRattachement='".$this->_OrganismeRattachement."'";
}
if(!empty($this->_LMD)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
LMD='".$this->_LMD."'";
}
if(!empty($this->_Discipline)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
Discipline='".$this->_Discipline."'";
}

if(!empty($this->_code_type_cand)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
code_type_cand='".$this->_code_type_cand."'";
}

if(!empty($this->_ville)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
ville='".$this->_ville."'";
}

if(!empty($this->_fonction)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
fonction='".$this->_fonction."'";
}
if(!empty($this->_grade)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
grade='".$this->_grade."'";
}

if(!empty($this->_specialite)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
specialite='".$this->_specialite."'";
}

if(!empty($this->_autreuniversite)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
autreuniversite='".$this->_autreuniversite."'";
}

if(!empty($this->_autreetablissement)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
autreetablissement='".$this->_autreetablissement."'";
}





$sql="UPDATE 
personne SET 
 ".$sql."
								WHERE NO ='".$this->_NO."'";

echo $sql;
$this->_cnn->connect();
$this->_result=$this->_cnn->query($sql);
 $this->_cnn->disconnect();
 if(!$this->_result){return 'erreur d\'execution de la requette';}else{return true;}
}

 public function DELETE(){

 $sql="DELETE FROM 
personne 
 
									WHERE NO ='".$this->_NO."'";
$this->_cnn->connect();
$this->_result=$this->_cnn->query($sql);
$this->_cnn->disconnect();
 if(!$this->_result){return 'erreur d\'execution de la requette';}else{return 'success';}
}

 public function TRANCATE(){

 $sql="DELETE FROM 
personne ";
$this->_cnn->connect();
$this->_result=$this->_cnn->query($sql);
$this->_cnn->disconnect();
 if(!$this->_result){return 'erreur d\'execution de la requette';}else{return 'success';}
}

 public function SELECT($constraint="",$pagination="")
{

$sql=" SELECT 
 		NO,
		Civilite,
		Titre,
		Nom,
		Prenom,
		CIN,
		login,
		MotPasse,
		Mail,
		AdressePostale,
		NumTelephone,
		NumFax,
		NumMobile,
		CategorieUsager,
		CategoriePrincipaleUsager,
		IdentifiantInstitutionnel,
		OrganismeRattachement,
		LMD,
		Discipline,
		code_type_cand,
		ville,
		fonction,
		grade,
		specialite,
		autreuniversite,
		autreetablissement
 FROM 
 personne";
if($constraint){$sql.=" WHERE 1=1 ".$constraint;}if($pagination){$sql.=$pagination;}
//echo $sql;
$this->_cnn->connect();
$this->_result=$this->_cnn->query($sql);
$this->_cnn->disconnect();
 if(!$this->_result){return 'erreur d\'execution de la requette';}else{return 'success';}
}
public function fetch_object(){
$row=mysql_fetch_object($this->_result);
 if($this->_result){
		if($row){
			$this->_NO=$row->NO;
			$this->_Civilite=$row->Civilite;
			$this->_Titre=$row->Titre;
			$this->_Nom=$row->Nom;
			$this->_Prenom=$row->Prenom;
			$this->_CIN=$row->CIN;
			$this->_login=$row->login;
			$this->_MotPasse=$row->MotPasse;
			$this->_Mail=$row->Mail;
			$this->_AdressePostale=$row->AdressePostale;
			$this->_NumTelephone=$row->NumTelephone;
			$this->_NumFax=$row->NumFax;
			$this->_NumMobile=$row->NumMobile;
			$this->_CategorieUsager=$row->CategorieUsager;
			$this->_CategoriePrincipaleUsager=$row->CategoriePrincipaleUsager;
			$this->_IdentifiantInstitutionnel=$row->IdentifiantInstitutionnel;
			$this->_OrganismeRattachement=$row->OrganismeRattachement;
			$this->_LMD=$row->LMD;
			$this->_Discipline=$row->Discipline;
			$this->_code_type_cand=$row->code_type_cand;
			$this->_ville=$row->ville;
			$this->_fonction=$row->fonction;
				$this->_grade=$row->grade;
					$this->_specialite=$row->specialite;
					
					$this->_autreuniversite=$row->autreuniversite;
					$this->_autreetablissement=$row->autreetablissement;
				
			return $row;
		}else{
			return false;
		}

		}else{
				//echo 'Erreur d\'execution de requette de selection';	
		}
			

		}

}
?>